package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Boo boo1 = new Boo();
        Boo boo2 = new Boo();
        Thread t1 = new Thread(){
            public void run(){
                boo1.doSome();
            }
        };
        Thread t2 = new Thread(){
            public void run(){
                boo2.doSome();
            }
        };
        t1.start();
        t2.start();
    }
}
class Boo {
    public static void doSome(){
        synchronized (Boo.class) {
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName() + "正在执行...");
                Thread.sleep(2000);
                System.out.println(t.getName() + "执行完毕...");
            } catch (InterruptedException e) {
            }
        }
    }
}
